<template>
    <div class=" wrap-table user-p1 user-move">
        <div class="headerTop_ukl">
            <ul class="clearfix">
                <li>
                    <p class="p1"><img src="../../assets/images/icon_yanjiuduixiang.png" alt=""/><span>研究对象</span></p>
                    <p class="p3">{{userBasic.Surname}}({{userBasic.ResearchNo}})</p>
                </li>
                <li>
                    <p class="p1"><img src="../../assets/images/icon_ganyuzu.png" alt=""/>{{userBasic.GroupType |GroupType}}</p>
                    <p  class="p3" v-if="userBasic.Period!='3'"><span v-if="userBasic.GroupType==1">{{userBasic.IntensityOfIntervention |IntensityOfIntervention}}</span></p>
                    <p  class="p3" v-else><span v-if="userBasic.GroupType==1">{{userBasic.ChildIntensityOfIntervention |IntensityOfIntervention}}</span></p>
                </li>
                <li >
                    <p class="p1"><img src="../../assets/images/icon_huaiyunqi.png" alt=""/>{{userBasic.Period |Period}}</p>
                    <p class="p3"><span v-if="userBasic.Period==2">预产期：{{userBasic.ExpectedDate}},{{userBasic.PregnancyWeek}}</span></p>
                    <p class="p3"><span v-if="userBasic.Period==3">出生日期：{{userBasic.ChildBirthDate}},{{userBasic.ChildAge}}, {{userBasic.ChildSex|ChildSex}} </span></p>
                     <p class="p3"><span v-if="userBasic.Period==4">出生日期：{{userBasic.ChildBirthDate}},{{getChildAge2(userBasic.ChildBirthDate)}}, {{userBasic.ChildSex|ChildSex}} </span></p>
                </li>
            </ul>
        </div>
        <!---->
        <template>
            <el-table
                    :data="tableData"
                    border
                    v-loading="loading"
                    height="500"
                    element-loading-text="加载中"
                    :default-sort = "{prop: 'CreateTime', order: 'descending'}"
                    style="width: 100%;">
                <el-table-column align="center" label="序号" width="70">
                    <template  slot-scope="scope">
                        {{scope.$index+1}}
                    </template>
                </el-table-column>
                <el-table-column
                        prop="CreateTime"
                        align="center"
                        sortable
                        label="创建时间"
                        min-width="130">
                </el-table-column>
                <el-table-column
                        prop="Title"
                        label="行动计划题目"
                        :show-overflow-tooltip="true"
                        align="center"
                        min-width="250">
                </el-table-column>
                <el-table-column
                        prop="PlanType"
                        label="分类"
                        :show-overflow-tooltip="true"
                        align="center"
                        min-width="120">
                </el-table-column>
                <el-table-column
                        prop="PlanCreater"
                        label="创建人"
                        align="center"
                        min-width="100">
                        <template slot-scope="scope">
                            <el-select v-model="scope.row.PlanCreater" placeholder="请选择" @change="changeNurse(scope.row,scope.row.PlanCreater)">
                                <el-option
                                        v-for="item in optionsNurse"
                                        :key="item.SYS_ID"
                                        :label="item.icons"
                                        :value="item.Surname+item.Name">
                                </el-option>
                            </el-select>
                        </template>
                </el-table-column>
                <el-table-column
                        prop="IsDraft"
                        label="状态"
                        align="center"
                        :formatter="UserStateFilter"
                        min-width="60">
                </el-table-column>
                <el-table-column
                        prop="Result"
                        label="结果评估"
                        align="center"
                        :formatter="ResultFilter"
                        min-width="150">
                </el-table-column>
                <el-table-column
                        min-width="60"
                        align="center"
                        fixed="right"
                        label="操作">
                    <template  slot-scope="scope">
                        <el-button v-if="scope.row.IsDraft==0" size="small" type="text" label="修改"  @click="handleEdit(scope.$index, scope.row)">修改</el-button>
                        <el-button v-else size="small" type="text" label="查看"  @click="handleCheck(scope.$index, scope.row)">查看</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </template>
        <!--分页-->
        <div class="block mg-20-auto">
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page.sync="pageId"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </div>
        <!--查看-->
        <el-dialog title="查看行动计划" :visible.sync="dialogForm1" :append-to-body="true" top="0" width="80%"
                   :close-on-click-modal="false">
            <div style="margin-right: 20px">
            <div class="formX">
	            <div style="margin: 10px 23px;" v-if="userBasic.Period == '3'">
		            <label>参与者</label>
		            <el-select :disabled="Plis" style="display:inline-block;width: 200px;margin-left: 16px"
		                       v-model="formx.FeedbackPerson" @change="changeOther">
			            <el-option value="1" label="研究对象自己"></el-option>
			            <el-option value="2" label="研究对象丈夫/伴侣"></el-option>
			            <el-option value="3" label="研究对象母亲"></el-option>
			            <el-option value="4" label="研究对象父亲"></el-option>
			            <el-option value="5" label="研究对象公公"></el-option>
			            <el-option value="6" label="研究对象婆婆"></el-option>
			            <el-option value="7" label="其他"></el-option>
		            </el-select>
		            <el-input :disabled="Plis"
		                      style="display: inline-block;width:355px;margin-left: 10px"
		                      v-if="formx.FeedbackPerson == 7"
		                      v-model="formx.FeedbackOther"
		                      placeholdyer="请输入具体内容">
		            </el-input>
	            </div>
                     <div class="top">
                         <label>题目</label>
                         <el-input
                                 :disabled="Plis"
                                 placeholder="请输入内容"
                                 v-model="formx.Title"
                                 style="display: inline-block;width: 570px !important;margin-left: 30px"
                                 clearable>
                         </el-input>
                     </div>

                    <div class="top">
                        <label>类别</label>
                        <el-select  v-if="parseInt(userBasic.Period) <= 3" :disabled="Plis"  v-model="formx.PlanType" placeholder="请选择" style="display:
                        inline-block;width:  570px !important;margin-left: 30px;margin-top: 15px;">
                            <el-option
                                    v-for="item in optionP"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                        <el-select  v-else :disabled="Plis"  v-model="formx.PlanType" placeholder="请选择" style="display:
                        inline-block;width:  570px !important;margin-left: 30px;margin-top: 15px;">
                            <el-option
                                    v-for="item in optionPC"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </div>

                <ul>
                    <li>
                        <h3>1.我目前的<span v-show="parseInt(userBasic.Period) > 2">育儿方式和孩子的健康</span>行为</h3>
              <!--<h5>当下你最想改变的行为是什么？</h5>-->
              <p>您最想优先考虑的<span v-show="parseInt(userBasic.Period) > 2">孩子行为和育儿方式</span>是什么?</p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                :disabled="Plis"
                                placeholder=""
                                v-model="formx.Q1">
                        </el-input>
                    </li>
                    <li>
                         <h3>2.我的SMARTER<span v-show="parseInt(userBasic.Period) > 2">育儿</span>目标</h3>
              <p>S具体的(您具体想要达到什么目标?)</p>
                        <el-input
                                type="textarea"
                                :disabled="Plis"
                                :rows="1"
                                placeholder=""
                                v-model="formx.Q2_1">
                        </el-input>
                        <p>M可衡量的(强度?频率? 时长?每天/周多少次?)</p>
                        <el-input
                                type="textarea"
                                :disabled="Plis"
                                :rows="1"
                                placeholder=""
                                v-model="formx.Q2_2">
                        </el-input>
                        <p>A易行的 (你将采取什么精确的行动?)</p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                placeholder=""
                                :disabled="Plis"
                                v-model="formx.Q2_3">
                        </el-input>
                        <p>R实际的(为达到你易行的<span v-show="parseInt(userBasic.Period) > 2">育儿</span>目标，你第一步要做什么?)</p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                :disabled="Plis"
                                placeholder=""
                                v-model="formx.Q2_4">
                        </el-input>
                        <p>T定时的 (完成你<span v-show="parseInt(userBasic.Period) > 2">育儿</span>目标的时刻表?)</p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                placeholder=""
                                :disabled="Plis"
                                v-model="formx.Q2_5">
                        </el-input>
                        <p>E可评估的(你如何评估你的<span v-show="parseInt(userBasic.Period) > 2">育儿</span>目标完成情况?)</p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                :disabled="Plis"
                                placeholder=""
                                v-model="formx.Q2_6">
                        </el-input>
                       <p>R可修改的(你什么时候可以回顾你的<span v-show="parseInt(userBasic.Period) > 2">育儿</span>目标并计划未来的任何变化？)</p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                :disabled="Plis"
                                placeholder=""
                                v-model="formx.Q2_7">
                        </el-input>
                        <p>你的SMARTER<span v-show="parseInt(userBasic.Period) > 2">育儿</span> 目标是</p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                :disabled="Plis"
                                placeholder=""
                                v-model="formx.Q2_8">
                        </el-input>
                    </li>
                    <li>
                        <h3>3.我的主要障碍是</h3>
                        <p>哪些事是阻止你达成目标的障碍? 请列举2-3个障碍。</p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                placeholder="①"
                                :disabled="Plis"
                                v-model="formx.Q3_1">
                        </el-input>
                        <p> </p>
                        <el-input
                                type="textarea"
                                :disabled="Plis"
                                :rows="1"
                                placeholder="②"
                                v-model="formx.Q3_2">
                        </el-input>
                        <p> </p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                :disabled="Plis"
                                placeholder="③"
                                v-model="formx.Q3_3">
                        </el-input>
                    </li>
                    <li>
                        <h3>4.我将采取的行动</h3>
                        <p>你可以做些什么来克服你的障碍?</p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                :disabled="Plis"
                                placeholder="①"
                                v-model="formx.Q4_1">
                        </el-input>
                        <p> </p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                placeholder="②"
                                :disabled="Plis"
                                v-model="formx.Q4_2">
                        </el-input>
                        <p> </p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                :disabled="Plis"
                                placeholder="③"
                                v-model="formx.Q4_3">
                        </el-input>
                    </li>
                    <li>
                        <h3>5. 我需要的资源</h3>
                        <p>什么资源可以帮助你克服障碍，实现<span v-show="parseInt(userBasic.Period) > 2">育儿</span>目标?</p>
                        <el-input
                                type="textarea"
                                :disabled="Plis"
                                :rows="1"
                                placeholder="①"
                                v-model="formx.Q5_1">
                        </el-input>
                        <p> </p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                :disabled="Plis"
                                placeholder="②"
                                v-model="formx.Q5_2">
                        </el-input>
                        <p> </p>
                        <el-input
                                type="textarea"
                                :rows="1"
                                :disabled="Plis"
                                placeholder="③"
                                v-model="formx.Q5_3">
                        </el-input>
                    </li>
                    <li>
                        <h3 v-show="parseInt(userBasic.Period) < 3">6.我的自信程度</h3>
              <h3 v-show="parseInt(userBasic.Period) > 2">您对实现您的育儿目标有多大信心</h3>
                        <p style="">
                            <el-rate
                                    v-model="formx.Q6"
                                    :disabled="Plis"
                                    style="margin:30px auto 30px 10px;"
                                    :colors="['#99A9BF', '#F7BA2A', '#FF9900']"
                                    :texts="showtexts"
                                    show-text>
                            </el-rate>
                        </p>
                    </li>
                    <li>
                        <h3>7.<span v-show="parseInt(userBasic.Period) > 2">育儿</span>目标的重要程度?</h3>
                        <p>达到目标对你来说有多重要?</p>
                        <p style="">
                            <el-rate
                                    v-model="formx.Q7"
                                    :disabled="Plis"
                                    style="margin:30px auto 30px 10px;"
                                    :colors="['#99A9BF', '#F7BA2A', '#FF9900']"
                                    :texts="showtexts2"
                                    show-text>
                            </el-rate>
                        </p>
                    </li>
                </ul>
                    <el-form v-if="formx.IsDraft==1">
                        <el-form-item label-width="105px" style="width: 300px;">
                            <span slot="label" style="font-size: 1.27em;color:orangered">结果评估</span>
                            <el-select v-model="formx.Result" placeholder="请选择" @change="resultChange">
                                <el-option
                                        v-for="item in options1"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <p v-if="formx.IsDraft==1" style="text-align: left">现在怎么样了？</p>
                    <template v-if="formx.IsDraft==1">
                        <el-table
                                :data="tableData1"
                                border
                                v-loading="loading1"
                                element-loading-text="拼命加载中"
                                style="width: 100%;margin-top: 15px;margin-bottom: 10px">
                            <el-table-column align="center" label="进展满意度" width="120" >
                                <template  slot-scope="scope">
                                    <img class="iconImg" v-if="scope.row.Satisfaction==1" src="../../assets/images/icon_happy_celected@2x.png" alt=""/>
                                    <img class="iconImg" v-else-if="scope.row.Satisfaction==2" src="../../assets/images/icon_ok_celected@2x.png" alt=""/>
                                    <img class="iconImg" v-else src="../../assets/images/icon_sad_celected@2x.png" alt=""/>
                                </template>
                            </el-table-column>
                            <el-table-column
                                    prop="CreateTime"
                                    align="center"
                                    label="反馈时间"
                                    min-width="100">
                            </el-table-column>
                            <el-table-column
                                    prop="LeaveMessage"
                                    label="留言"
                                    align="center"
                                    min-width="300">
                            </el-table-column>
                            <el-table-column
                                    min-width="120"
                                    align="center"
                                    label="操作">
                                <template  slot-scope="scope">
                                    <div style="display: flex;">
                                        <el-checkbox style="flex: 1" true-label="1" false-label="0" v-model="scope.row.IsRead" @change="IsReadFcu(scope.row)" >已阅</el-checkbox>
                                        <el-checkbox style="flex: 1" true-label="1" false-label="0" v-model="scope.row.IsContect" @change="IsReadFcu(scope.row)" >已致电</el-checkbox>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </template>
                   
                    <p v-if="formx.IsDraft==1" style="text-align: left;margin:15px 0px;">习惯养成记录</p>
                    <echarts :options="chartsInfo1" chartId="chartsInfo1"></echarts>
                <div slot="footer" class="dialog-footer" v-if="formx.IsDraft==0">
                    <el-button @click="dialogForm1 = false">关 闭</el-button>
                    <el-button @click="submitForm(0)">保存草稿</el-button>
                    <el-button type="primary" @click="submitForm(1)">提交</el-button>
                </div>
                <div v-else class="dialog-footer">
                    <el-button type="primary" @click="dialogForm1 = false">关 闭</el-button>
                </div>
                </div>
                </div>
        </el-dialog>
    </div>
</template>
<script>
import {mapGetters} from 'vuex'
import echarts from "../home/echarts.vue"
import {getChildAge2} from '@/utils/index'
import {filterPeriod,filterIntensityOfIntervention} from '@/utils/localDic'
export default {
    name:'userP1',
    data() {
        return {
            tableData:[],
            pageId:1,
            total:null,
            loading:false,
            pageSize:10,
            dialogForm1:false,
            tableData1:[],
            pageId1:1,
            total1:null,
            loading1:true,
            pageSize1:10,
            itemType:'',
            sysId:'',
            researchNo:'',
            mobile:'',
            Plis:false,
            showtexts:['一点也没有', '', '有一点', '', '完全有信心'],
            showtexts2:['不重要', '', '一般', '', '非常重要'],
            formx:{
                Title:'',
                Q1:'',
                Q2_1:'',
                Q2_2:'',
                Q2_3:'',
                Q2_4:'',
                Q2_5:'',
                Q2_6:'',
                Q2_7:'',
                Q2_8:'',
                Q3_1:'',
                Q3_2:'',
                Q3_3:'',
                Q4_1:'',
                Q4_2:'',
                Q4_3:'',
                Q5_1:'',
                Q5_2:'',
                Q5_3:'',
                Q6:null,
                Q7:null,
                Result:null,
                IsDraft:'',
                PlanType:''
            },
            userBasic:{
                Surname:'',
                ResearchNo:'',
                ExpectedDate:'',
                Period:'',
                IntensityOfIntervention:'',
                GroupType:''
            },
            changeVal:'混合显示模式',
	        optionPC:[
        { value: "育儿方式&营养", label: "育儿方式&营养" },
        { value: "育儿方式&身体活动", label: "育儿方式&身体活动" },
        { value: "育儿方式&睡眠", label: "育儿方式&睡眠" },
        { value: "育儿方式&视屏时间", label: "育儿方式&视屏时间" },
        { value: "其他", label: "其他" },
      ],
            optionP: [{ value: "母乳喂养", label: "母乳喂养" },
        { value: "环境", label: "环境" },
        { value: "营养", label: "营养" },
        { value: "身体活动", label: "身体活动" },
        { value: "心理健康", label: "心理健康" },
        { value: "睡眠", label: "睡眠" },
        { value: "吸烟", label: "吸烟" }],
            options: [{value: '0', label: '混合显示模式'}, {value: '1', label: '只显示频率问卷'},{value: '2', label: '只显示重要程度问卷'}],
            UserStateFilter(row, column, cellValue, index){
                return cellValue==1?'已发送':'草稿'
            },
            ResultFilter(row, column, cellValue, index){
                switch(cellValue){
                    case '1':
                        return '目标达成';
                        break;
                    case '2':
                        return '目标部分达成'
                        break;
                    case '3':
                        return '没有改变';
                        break;
                    case '4':
                        return '情况更糟'
                }
            },
            Satisfaction(row, column, cellValue, index){
                if(cellValue==1){
                    return '满意'
                }
                else if(cellValue==2){
                    return '一般'
                }
                else{
                    return '不满意'
                }
            },
            optionsNurse:[],
            options1:[{value:'1', label: '目标达成'}, {value:'2', label: '目标部分达成'},{value: '3', label: '没有改变'}, {value: '4', label: '情况更糟'}],
            chartsInfo1:{    //习惯养成记录
                color:['#d4f4b7','#d1e8fc',' #e2e2e2','#e2e2e2'],
                    tooltip : {
                    trigger: 'item',
                    formatter:function(b,c){
                        var value=''
                        switch (b.data){
                            case '4':
                                value='跳过'
                                break;
                            case '3':
                                value='未完成'
                                break;
                            case '2':
                                value='进行中'
                                break;
                            case '1':
                                value='已完成'
                                break;
                        }
                        return b.name+' \n'+'('+value+')'

                    }
                },
                calculable : false,
                        dataZoom: [
                    {
                        show: true,
                        start: 0,
                        end: 100
                    },
                    {
                        type: 'inside',
                        start:0,
                        end: 100
                    },
                ],
                legend: {
                    data:[1,2,3,4]
                },
                xAxis: {
                    type: 'category',
                    name:'',
                    nameLocation: 'end',
                            axisLabel: {
                        rotate: 45, //刻度旋转45度角
                                textStyle: {
                            color: "#333333",
                                    fontSize: 14
                        }
                    },
                    position:'bottom',
                    nameGap:'30',
                    data:[]
                },
                grid: {
                    left: '3%',
                    right: '8%',
                    bottom: '10%',
                    containLabel: true
                },
                yAxis: {
                    type: 'category',
                    name:'',
                    data:[1,2,3,4],
                    boundaryGap:false,  //是否居中对齐
                    axisTick: {
                        show: false,
                    },
                    splitLine:{      //去掉背景水平网格线
                        show:true
                    },
                    axisLabel: {
                        show:true,
                        formatter:function(value){
                            var name=[]
                            switch (value){
                                case '4':
                                    name.push('跳过');
                                    break;
                                case '3':
                                    name.push('未完成');
                                    break;
                                case '2':
                                    name.push('进行中');
                                    break;
                                case '1':
                                    name.push('已完成');
                                    break;
                            }
                            return name
                        }
                    }
                },
                series: [{
                    data: [],
                    barWidth :39,
                    type: 'scatter',
                    itemStyle: {    //动态设置散点图颜色
                        normal: {
                            color: function(params) {
                                var colorList = ['#00CC00','#0099FF',' #949494','#949494']
                                return colorList[parseInt(params.data)-1]
                            }
                        }
                    }
                }]
            },
        }
    },
    components:{
        echarts
    },
    props:{
        changeIndex:{
            type: String,
        }
    },
    watch:{
        changeIndex:function(index){
            if(index=='4'){
                this.getList()
            }
        }
    },
    computed:{
        ...mapGetters([
                'resechObj',
            ]),
        LASTTIME:function(){
            let dateAlary=new Date(this.userBasic.ExpectedDate)
            return new Date(dateForm(dateAlary.setMonth(dateAlary.getMonth()-9,dateAlary.getDate()-7)))
        },
        yunzhou:function(){
            return parseInt((WeeksBetw(new Date,this.LASTTIME))/7)
        },
        yuntianshu:function(){
            return parseInt((WeeksBetw(new Date,this.LASTTIME))%7)
        },
        birthWeek(){
            return parseInt((WeeksBetw(new Date,new Date(this.userBasic.ChildBirthDate)))/7)    
        },
        birthDay(){
            return parseInt((WeeksBetw(new Date,new Date(this.userBasic.ChildBirthDate)))%7)
        }
    },
    created() {
        
    },
    methods: {
         getChildAge2(val){ //获取儿童期2年龄
            return val && getChildAge2(val)
        },
        handleSizeChange(val) {       //条数改变
            this.pageSize=val;
            this.getList()
        },
        handleCurrentChange(val) {    //页数改变
            this.pageId = val
            this.getList()
        },
        GetNurse:function(){
            let that=this;
            that.service({
                url:'/Sys/GetNurse',
                method:'get',
                params:{
                    roleGroup:'3'
                }
            }).then(response=>{
                let options=response.dtData
                for(let i of options){    //处理姓名账号不一致，Nan
                i.Name=i.Name || ''
                let username=i.Surname+i.Name
                username=='undefined'?username=i.UserCode:username=username
                i.icons=username
            }
                that.optionsNurse=options;
            }).catch(data=>{

            })
        },
        handleSizeChange1(val) {       //条数改变11
            this.pageSize1=val;
            this.getList()
        },
	    changeOther(){
            this.formx.FeedbackOther = ''
        },
        handleCurrentChange1(val) {    //页数改变11
            this.pageId1 = val
            this.getList()
        },
        handleEdit:function(index,row){  //修改
            let that=this
            that.Plis=false
            that.formx=JSON.parse(JSON.stringify(row));
            that.formx.Q6=parseInt(that.formx.Q6);
            that.formx.Q7=parseInt(that.formx.Q7)
            that.dialogForm1=true
            that.Getrecord(row.SYS_ID)
        },
        handleCheck:function(index,row){   //查看
            let that=this;
            that.formx=JSON.parse(JSON.stringify(row));
            that.formx.Q6=parseInt(that.formx.Q6)
            that.formx.Q7=parseInt(that.formx.Q7)
            that.Plis=true
            that.dialogForm1=true
            that.GetPlanFeedBack()
            that.Getrecord(row.SYS_ID)
        },
        Getrecord:function(id){   //获取习惯养成记录
            let that=this;
            that.service({
                url:'/ResearchObject/GetPlanCustomRecord',
                method:'get',
                params:{
                        planId:id
                    }
                }).then(response=>{
                    let arr1=[];
                    let arr2=[];
                    response.dtData.map(val=>{
                        arr1.push(val.RecordState)
                        arr2.push(val.RecordDate)
                        console.log(val)
                    })
                    that.chartsInfo1.xAxis.data=arr2
                    that.chartsInfo1.series[0].data=arr1
            }).catch(data=>{

            })
        },
        addInfo:function(){  //添加
            this.dialogForm1=true
        },
        GetPlanFeedBack:function(){
            let that=this;
            that.loading1=true;
            that.service({
                url:'/ResearchObject/GetPlanFeedBack',
                method:'get',
                params:{
                    planId:that.formx.SYS_ID
                }
                }).then(response=>{
                    that.tableData1=response.dtData;
                    that.loading1=false
                }).catch(data=>{
                    that.loading1=false
            })
        },
        changeNurse:function(row,val){ //修改护士
            let that=this;
            this.$confirm('是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                that.service({
                        url:'/ResearchObject/SavePlan',
                        method:'post',
                        data:{...row}
                        }).then(response=>{
                            that.getList()
                            that.$message({
                                message:'修改成功',
                                type:'success'
                            })
                    }).catch(data=>{
                })
            }).catch(() => {
                that.getList()
                that.$message({
                    message:'已取消',
                    type:'info'
                })

            });
        },
        IsReadFcu:function(row){
            let that=this;
            let rowNew=JSON.parse(JSON.stringify(row))
            that.service({
                url:'/ResearchObject/SavePlanFeedback',
                method:'post',
                data:{
                        ...rowNew
                }
            }).then(response=>{
                that.$message({
                    message:'修改成功',
                    type:'success'
                })
                that.GetPlanFeedBack()
            }).catch(data=>{
            })
        },
        submitForm:function(type){   //提交
            let that=this;
            if((this.formx.Title==''||this.formx.Q1==''||this.formx.Q2_1==''||this.formx.Q2_2==''||this.formx.Q2_3==''||this.formx.Q2_4==''||this.formx.Q2_5==''||this.formx.Q2_6==''||this.formx.Q2_7==''||this.formx.Q2_8==''||this.formx.Q3_1==''||this.formx.Q4_1==''||this.formx.Q5_1==''||this.formx.Q6==''||this.formx.Q7=='')&&(type==1 ||this.formx.Title=='')){
                that.$message({
                    message: '所有项为必填，请认真填写，草稿需填写标题',
                    type: 'warning'
                });
                return false;
            }
            that.service({
                url:'/ResearchObject/SavePlan',
                method:'post',
                data:{
                    ResearchObjectId:that.sysId,
                    ...that.formx,
                    IsDraft:type,
                    Result:null
                }
                }).then(response=>{
                    that.dialogForm1=false
                    that.getList()
                }).catch(data=>{
            })
        },
        resultChange:function(val){  //状态评估
            let that=this;
            that.service({
                url:'/ResearchObject/SavePlan',
                method:'post',
                data:{
                    ResearchObjectId:that.sysId,
                    ...that.formx,
                    IsDraft:1,
                    Result:val
                }}).then(response=>{
                    that.$message({
                        message:'修改成功',
                        type:'success'
                    })
                    that.getList()
                }).catch(data=>{
            })
        },
        getList:function(){           //获取一级信息列表
            let that=this
            that.userBasic=''
            if(that.resechObj.mobile ||that.resechObj.researchNo){
                that.sysId='';
                that.mobile=that.resechObj.mobile;
                that.researchNo=that.resechObj.researchNo;
            }
            that.service({
                url:'/ResearchObject/GetParticipantDetail',
                method:'get',
                params:{
                    itemType:'5',
                    sysId:'',
                    period:'',
                    researchObjectId:that.sysId,
                    mobile:that.mobile,
                    researchNo:that.researchNo,
                    pageCount:(that.pageId-1),
                    pageSize:that.pageSize,
                }
                }).then(response=>{
	                console.log(response)
                    response.dtData.dtBasic[0]?that.userBasic=response.dtData.dtBasic[0]:''
                    that.tableData=response.dtData.dtPlan;
                    that.total=parseInt(response.dtData.dtPlan[0].TotalCount)
            }).catch(data=>{
            })
        },
    },
    mounted:function(){
        let that=this;
        that.sysId=that.$route.query.id;
        that.mobile=that.$route.query.mobile;
        that.researchNo=that.$route.query.researchNo;
        that.getList()
        that.GetNurse()
    },
    filters:{
        GroupType:function(val){
            if(val=='' ||val==undefined){
                return ''
            }
            return val=='1'?'A': 'B'
        },
        IntensityOfIntervention:function(val){
             return filterIntensityOfIntervention(val)
        },
        Period:function(val){
             return filterPeriod(val)
        },
        ChildSex(val){
	        return val=='1'?'男':val=='2'?'女':'未知'
        }
    }
  }
function addZero(s){
    return s < 10 ? '0' + s: s;
}

function dateForm(data){   //日期格式化
    return   new Date(data).getFullYear()+'-'+addZero((new Date(data).getMonth()+1))+'-'+addZero(new Date(data).getDate())
}
function WeeksBetw(date1,date2) {  //计算日期之间相差得天数
    var _dt1=new Date(date1);
    var _dt2=new Date(date2);
    var dt1=_dt1.getTime();
    var dt2=_dt2.getTime();
    return parseInt(Math.abs(dt1- dt2)/1000/60/60/24);//这里是计算天数,如果想获得周数则在该返回值上再除以7
}
</script>
<style scoped lang="scss">
    .user-p1{
        .headerTop{
            margin-bottom:30px;
            p{
                font-size:16px;
                margin-bottom: 15px;
                color:#303133;
            span{
                padding:10px;
            }
            .span1{
                margin-left: 25px;
            }
        }
    }
    .user-pi-ul{
        margin:0px auto 20px auto;
        li{
            float: left;
            width: 200px;
            margin-right: 20px;
        }
    }

    }
    .formX{
        .top{
            text-align: left;
            margin-left: 23px;
	        label{

	        }
        }
        ul{
            li{
                margin:20px;
                h3{
                    color: #606266;
                    font-weight: normal;
                    font-size: 14px;
                }
                h5{
                    font-weight: normal;
                    margin:5px 0;
                }
                p{
                    color: #999999;
                    margin-bottom: 10px;
                    margin:10px 0px;
                }
            }
        }
    }
    .headerTop_ukl{
        /*border:1px solid #EDF1F7;*/
        padding:5px 20px 10px 0px;
        min-width: 800px;
        width:1000px;
        font-size:14px;
    ul{
    li{
        float: left;
        margin-right: 50px;
    .p1{
        color:#999999;
        padding-bottom:5px;
        display: inline-block;
    img{
        display: inline-block;margin-right: 10px;
    };

    }
    .p3{
        display: inline-block;
        padding-left: 10px;
        color: #666;
    }
    }
    }
    }
    .isReadspan{cursor: pointer;color: #0066FF}
    .iconImg{width: 30px;height: 30px;}
</style>
